<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>会议系统</title>

</head>
<body>
<jsp:include page="/incloud/header.jsp" />
<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <jsp:include page="/incloud/sidebar.jsp" />
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">会议系统</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="list-group ">
                <!--搜索文章的条件-->
                <div class="myTitle">
                    <form class="form-inline">
                        <div class="form-group">
                            <label for="inlineFormInput" class="sr-only">Name</label>
                            <input id="inlineFormInput" value="${title}" type="text" placeholder="按标题名字查找" class="mr-sm-3 form-control">
                        </div>
                        
                        <!--选择状态-->
                        <div class="form-group" style="margin-right: 20px;">
                            <select name="dep" class="form-control selectpicker" id="status">
                                <option value="-1" ${status == -1?'selected':''}>请选择状态</option>
                                <option value="0" ${status == 0?'selected':''}>未开始</option>
                                <option value="1" ${status == 1?'selected':''}>正在进行</option>
                                <option value="2" ${status == 2?'selected':''}>已结束</option>
                            </select>
                        </div>
						<div class="form-group">
						    <input type="button" onclick="search()" value="查询" class="btn btn-primary mr-sm-3 ">
						</div>
                    </form>

                    <input id = "addMeet" type="submit" value="发布会议" class="btn btn-primary">


                </div>

                <ul class="myList">
                    <c:forEach items="${meetingList}" var="meeting">
                    <li class="list-group-item">
                        <div style="float: right;">
                            <c:if test="${meeting.status == 0}"><span><strong>状态：未开始</strong></span></c:if>
                            <c:if test="${meeting.status == 1}"><span><strong>状态：进行中</strong></span></c:if>
                            <c:if test="${meeting.status == 2}"><span><strong>状态：已结束</strong></span></c:if>
                        </div>
                        <a href="/meeting/lookMeetingInfo?id=${meeting.id}">${meeting.title}</a>
                        <p class="h6"><strong>部门：</strong>${meeting.deptName}</p>
                        <p class="h6"><strong>发布日期：</strong>${meeting.publishDate}</p>
                        <p class="h6"><strong>开始时间：</strong>${meeting.startTime}</p>
                        <p style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis">${meeting.content}</p>
                    </li>

                    </c:forEach>
                </ul>

                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <c:if test="${meetingPageUtils.pageCount > 0}">
                        <li>
                            <a href="javascript:0;" onclick="pre(${meetingPageUtils.cureePage})" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach begin="1" end="${meetingPageUtils.pageCount}" varStatus="index">
                        <li><a href="/meeting/findAll?cureePage=${index.count}&title=${title}&status=${status}">${index.count}</a></li>
                        </c:forEach>
                        <li>
                            <a href="javascript:0;" onclick="next(${meetingPageUtils.cureePage})" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                        </c:if>
                    </ul>
                </nav>
            </div>
        </section>

        <jsp:include page="/incloud/footer.jsp" />
    </div>
</div>

</body>
</html>
<script type="text/javascript">
    //根据文章名模糊查询文章信息
    function search() {
        var status = $("#status").val();
        var searchName = $("#inlineFormInput").val();
        location.href = "/meeting/findAll?cureePage=1&title="+searchName+"&status="+status;
    }
    //上一页
    function pre(cureePage){
        var status = $("#status").val();
        if(cureePage - 1 < 1){
            layer.msg("已经是第一页了")
            return;
        }
        //cureePage = cureePage -1 ;
        location.href = "/meeting/findAll?cureePage="+(cureePage-1)+"&title="+$("#inlineFormInput").val()+"&status="+status;
    }
    //下一页
    function next(cureePage){
        var status = $("#status").val();
        if(cureePage +1 > ${meetingPageUtils.pageCount}){
            layer.msg("已经是最后一页了")
            return;
        }
        //cureePage = cureePage +1 ;
        location.href = "/meeting/findAll?cureePage="+(cureePage+1)+"&title="+$("#inlineFormInput").val()+"&status="+status;
    }


    $("#avatar").click(function () {
        location.href = "/user/detail?id=${loginUser.id}";
    })

	//发布会议跳转链接
	$("#addMeet").click(function () {
	    window.location.href = '/html/meeting_add.jsp'
	});
</script>